﻿using System.Diagnostics;
using AzureContrib.WindowsAzure.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NuGet.Testes
{
	[TestClass]
	public class TestingTheNugetTests
	{
		[TestMethod]
		public void UsingTheNuget()
		{
			Assert.AreEqual('/', AzureContrib.WindowsAzure.Utils.UriExtensions.Slash);

			ITrace trace = new WindowsAzureTraceFactory(TraceLevel.Info).Create(GetType());

			Assert.AreEqual(GetType().FullName, trace.Switch);
			Assert.IsFalse(trace.Disabled);
			Assert.IsFalse(trace.VerboseEnabled);
			Assert.IsTrue(trace.InformationEnabled);
			Assert.IsTrue(trace.WarningEnabled);
			Assert.IsTrue(trace.ErrorEnabled);
		}

		[TestMethod]
		public void Injecting_a_tracer()
		{
			var traceFactory = new WindowsAzureTraceFactory(TraceLevel.Info);

			var trace = traceFactory.Create(typeof(Foo));

			var foo = new Foo(trace);

			foo.SomeMethod();
		}

		public class Foo
		{
			private readonly ITrace trace;

			public Foo(ITrace trace)
			{
				this.trace = trace;
			}

			public void SomeMethod()
			{
				trace.Information("Write some trace...");
			}
		}
	}
}